package aip.core.model.user;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.util.StringUtils;

@Entity
@Table(name = "USER_COMPANY")
public class Company implements Serializable
{
    private static final long serialVersionUID = 6078290446981987223L;
    private String username;
    /** 公司地址 */
    private String address;
    /** 所属行业 */
    private String domainStr;
    /** 企业规模 */
    private String size;
    /** 网络建设情况 */
    private String netStatusStr;
    /** 专有系统建设情况 */
    private String systemStatusStr;
    /** 拥有自有IT队伍 */
    private String itGroupSize;
    /** 联系人 */
    private String contact;
    /** 联系电话 */
    private String phone;
    /** 电子邮件 */
    private String email;

    /**
     * @return the username
     */
    @Id
    @Column(name = "USERNAME_")
    public String getUsername()
    {
        return username;
    }

    /**
     * @param username
     *        the username to set
     */
    public void setUsername(String username)
    {
        this.username = username;
    }

    /**
     * @return the address
     */
    @Column(name = "ADDRESS_")
    public String getAddress()
    {
        return address;
    }

    /**
     * @param address
     *        the address to set
     */
    public void setAddress(String address)
    {
        this.address = address;
    }

    /**
     * @return the domainStr
     */
    @Column(name = "DOMAIN_")
    public String[] getDomain()
    {
        return StringUtils.hasText(domainStr) ? domainStr.substring(1,
                domainStr.length() - 1).split("|") : new String[] {};
    }

    public Set<String> getDomainSet()
    {
        Set<String> result = new HashSet<String>();
        result.addAll(Arrays.asList(this.getDomain()));
        return result;
    }

    /**
     * @param domainStr
     *        the domainStr to set
     */
    public void setDomain(String[] domain)
    {
        this.domainStr = '|' + StringUtils.arrayToDelimitedString(domain, "|") + '|';
    }

    /**
     * @return the size
     */
    @Column(name = "SIZE_")
    public String getSize()
    {
        return size;
    }

    /**
     * @param size
     *        the size to set
     */
    public void setSize(String size)
    {
        this.size = size;
    }

    /**
     * @return the netStatusStr
     */
    @Column(name = "NET_STATUS_")
    public String[] getNetStatus()
    {
        return StringUtils.hasText(netStatusStr) ? netStatusStr.substring(1,
                netStatusStr.length() - 1).split("|") : new String[] {};
    }

    public Set<String> getNetStatusSet()
    {
        Set<String> result = new HashSet<String>();
        result.addAll(Arrays.asList(this.getNetStatus()));
        return result;
    }

    /**
     * @param netStatusStr
     *        the netStatusStr to set
     */
    public void setNetStatus(String[] netStatus)
    {
        this.netStatusStr = '|' + StringUtils.arrayToDelimitedString(netStatus,
                "|") + '|';
    }

    /**
     * @return the systemStatusStr
     */
    @Column(name = "SYS_STATUS_")
    public String[] getSystemStatus()
    {
        return StringUtils.hasText(systemStatusStr) ? systemStatusStr
                .substring(1, systemStatusStr.length() - 1).split("|")
                : new String[] {};
    }

    public Set<String> getSystemStatusSet()
    {
        Set<String> result = new HashSet<String>();
        result.addAll(Arrays.asList(this.getSystemStatus()));
        return result;
    }

    /**
     * @param systemStatusStr
     *        the systemStatusStr to set
     */
    public void setSystemStatus(String[] systemStatus)
    {
        this.systemStatusStr = '|' + StringUtils.arrayToDelimitedString(
                systemStatus, "|") + '|';
    }

    /**
     * @return the itGroupSize
     */
    @Column(name = "IT_GP_SIZE_")
    public String getItGroupSize()
    {
        return itGroupSize;
    }

    /**
     * @param itGroupSize
     *        the itGroupSize to set
     */
    public void setItGroupSize(String itGroupSize)
    {
        this.itGroupSize = itGroupSize;
    }

    /**
     * @return the contact
     */
    @Column(name = "CONTACT_")
    public String getContact()
    {
        return contact;
    }

    /**
     * @param contact
     *        the contact to set
     */
    public void setContact(String contact)
    {
        this.contact = contact;
    }

    /**
     * @return the phone
     */
    @Column(name = "PHONE_")
    public String getPhone()
    {
        return phone;
    }

    /**
     * @param phone
     *        the phone to set
     */
    public void setPhone(String phone)
    {
        this.phone = phone;
    }

    /**
     * @return the email
     */
    @Column(name = "EMAIL_")
    public String getEmail()
    {
        return email;
    }

    /**
     * @param email
     *        the email to set
     */
    public void setEmail(String email)
    {
        this.email = email;
    }

    /**
     * @return the netStatusStr
     */
    public String getNetStatusStr()
    {
        return netStatusStr;
    }

    /**
     * @param netStatusStr
     *        the netStatusStr to set
     */
    public void setNetStatusStr(String netStatusStr)
    {
        this.netStatusStr = netStatusStr;
    }

    /**
     * @return the domainStr
     */
    public String getDomainStr()
    {
        return domainStr;
    }

    /**
     * @param domainStr
     *        the domainStr to set
     */
    public void setDomainStr(String domainStr)
    {
        this.domainStr = domainStr;
    }

    /**
     * @return the systemStatusStr
     */
    public String getSystemStatusStr()
    {
        return systemStatusStr;
    }

    /**
     * @param systemStatusStr
     *        the systemStatusStr to set
     */
    public void setSystemStatusStr(String systemStatusStr)
    {
        this.systemStatusStr = systemStatusStr;
    }
}
